from socket import *
import threading


address='0.0.0.0'
port=12345
buffsize=1024
s = socket(AF_INET, SOCK_STREAM)
s.bind((address,port))
s.listen(10)

def tcplink(sock,addr):
    while True:
        recvdata=clientsock.recv(buffsize).decode('utf-8')
        if recvdata=='exit' or not recvdata:
            break
        senddata=recvdata+' 你好，from sever'
        clientsock.send(senddata.encode())
    clientsock.close()

while True:
    clientsock, clientaddress = s.accept()
    print('connect from:', clientaddress)
    t = threading.Thread(target=tcplink, args=(clientsock, clientaddress))
    t.start()

